﻿using LJ.Abstractions.Pack;
using LJ.Abstractions.Pack.Attributes;
using LJ.StreamSystem.LazyHare;
using LJ.StreamSystem.LazyHare.Internal;
using LJ.StreamSystem.LazyHare.Transport.Abstractions.Pack;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.StreamSystem.Abstractions.Pack;

[DependPack(typeof(IStreamSystemLazyHareTransportPack))]
public abstract class StreamSystemStreamizPackBase : PackBase, IStreamSystemPack
{
    public override void Add(IPackContext packContext)
    {

        var streamSystemManager = new StreamSystemManager(packContext.DependencyManager, packContext.ReflectionManager);
        packContext.DependencyManager.ServiceCollection.AddSingleton<IStreamSystemManager>(streamSystemManager);

        packContext.DependencyManager.ServiceCollection.AddSingleton<IStreamSystemMessageSerializer, StreamSystemMessageSerializer>();

        packContext.DependencyManager.ServiceCollection.AddTransient<IAggregateStreamSystemSubscribe, AggregateStreamSystemSubscribe>();

        packContext.DependencyManager.ServiceCollection.AddTransient<IAggregateStreamSystemHandlerInvoker, AggregateStreamSystemHandlerInvoker>();

        packContext.DependencyManager.ServiceCollection.AddTransient<IAggregateStreamSystemMessageListener, AggregateStreamSystemMessageListener>();

        packContext.DependencyManager.ServiceCollection.AddScoped<IAggregateStreamSystemSubscribe, AggregateStreamSystemSubscribe>();
    }

    public override void Use(IPackProvider packProvider)
    {
    }
}
